<?php

class DefaultApp extends MallbaseApp
{
	function index()
	{
		$db=&db();
			
		$sql="select * from zys_shippingline where isuse=1 order by sort_order limit 3";
		$ship=$db->getAll($sql);
			

		$sql="select * from zys_shippingline where isuse=1 order by sort_order";
		$shipall=$db->getAll($sql);

		$list=array();
		if($shipall){
			foreach ($shipall as $v){
				$p=pinyin::to_first($v['code']);
				if(empty($p)){
					$p='z';
				}
				$psort[]=$p;
				$new_array[]=$v;
			}

			array_multisort($psort, SORT_ASC, $new_array);

			if($new_array){
				foreach ($new_array as $v){
					$p=pinyin::to_first($v['code']);
					if(empty($p)){
						$p='z';
					}
					if($p=='a'||$p=='b'||$p=='c'){
						$list['ABC']['p']='ABC';
						$list['ABC']['item'][]=$v;
					}
					if($p=='d'||$p=='e'||$p=='f'||$p=='g'){
						$list['DEFG']['p']='DEFG';
						$list['DEFG']['item'][]=$v;
					}
					if($p=='h'||$p=='i'||$p=='g'){
						$list['HIJ']['p']='HIJ';
						$list['HIJ']['item'][]=$v;
					}
					if($p=='k'||$p=='l'||$p=='m'){
						$list['KLM']['p']='KLM';
						$list['KLM']['item'][]=$v;
					}
					if($p=='n'||$p=='o'||$p=='p'||$p=='r'){
						$list['NOPR']['p']='NOPR';
						$list['NOPR']['item'][]=$v;
					}
					if($p=='s'||$p=='t'||$p=='u'||$p=='y'||$p=='z'){
						$list['STUWYZ']['p']='STUWYZ';
						$list['STUWYZ']['item'][]=$v;
					}
				}
			}
		}

		$alist=array();
		$sql="select * from zys_article where cate_id=5 and if_show=1 order by sort_order limit 7";
		$article=$db->getAll($sql);
		foreach ($article as $v){
			$v['add_time']=local_date('m-d',$v['add_time']);
			$alist[]=$v;
		}

		$this->assign('alist', $alist);
		$this->assign('list', $list);
		$this->assign('ship', $ship);
		$this->assign('index', 1);
			
		$sql="select article_id from zys_article where code='js'";
		$js=$db->getOne($sql);
		$this->assign('js', $js);

		$sql="select article_id from zys_article where code='xs'";
		$xs=$db->getOne($sql);
		$this->assign('xs', $xs);

		$sql="select article_id from zys_article where code='jr'";
		$jr=$db->getOne($sql);
		$this->assign('jr', $jr);

		$sql="select article_id from zys_article where code='bj'";
		$bj=$db->getOne($sql);
		$this->assign('bj', $bj);

		$uid=$this->visitor->get('user_id');
		$uid=empty($uid)?0:intval($uid);
		$sql="select fx from zys_member where user_id=".$uid;
		$f=$db->getOne($sql);

		if($f){
			$this->display('newindex1.html');	
		}else{
			$this->display('newindex.html');
		}
	}
}


?>
